<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Knockout.js</title>

  <link rel="stylesheet" href="style.css" />
</head>

<body>
  <div id="root">
    <div>
      显示/隐藏 checkbox 面板 <input type="checkbox" data-bind="checked:checkbox.showPanel" />
    </div>
    <div>显示/隐藏 radio 面板 <input type="checkbox" data-bind="checked:radio.showPanel" /></div>

    <div data-bind="visible:checkbox.showPanel" class="panel">
      <p>颜色列表</p>
      <div data-bind="foreach:colorList">
        <div class="box" data-bind="style:{'background-color':$data}">
          <input type="checkbox" data-bind="value:$data,checked:$parent.checkbox.selectedColorList" />
        </div>
      </div>
      <p>选择的颜色列表</p>
      <div data-bind="foreach:checkbox.selectedColorList">
        <div class="box" data-bind="style:{'background-color':$data}"></div>
      </div>
    </div>
    <div data-bind="visible:radio.showPanel" class="panel">
      <p>颜色列表</p>
      <div data-bind="foreach:colorList">
        <div class="box" data-bind="style:{'background-color':$data}">
          <input type="radio" data-bind="value:$data,checked:$parent.radio.selectedColor" />
        </div>
      </div>
      <p>选择的颜色</p>
      <div class="box" data-bind="style:{'background-color':radio.selectedColor}"></div>
    </div>
    <script src="../scripts/lib/require.js" data-main="index.js"></script>
</body>

</html>